package com.ht.api.task;

import org.springframework.stereotype.Component;

import com.ht.api.db.exception.HtException;
import com.ht.api.db.task.TaskHandler;
import com.ht.api.open.OpenUtil;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

/**
 * 给用户打标签
 * @author asq
 * @createTime 2025年3月2日 19:13:39
 */
@Component
public class TagTestTask implements TaskHandler{

	@Override
	public String getName() {
		return "给用户打标签";
	}

	@Override
	public boolean handler(JSONObject requestParam, String groupId, long taskId) {

//		{
//			"userid":"zhangsan",
//			"external_userid":"woAJ2GCAAAd1NPGHKSD4wKmE8Aabj9AAA",
//			"add_tag":["TAGID1","TAGID2"],
//			"remove_tag":["TAGID3","TAGID4"]
//		}
		
		System.err.println("TagTestTask  给用户打标签");
		String str = OpenUtil.call("1876990838014349312", 1896150837936394240L, requestParam);
		
		JSONObject result = JSONUtil.parseObj(str);
		if (result.getInt("errcode") == 0) {
			return true;
		} else {
			throw new HtException(str);
		}
	}

}
